# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-maxminddb
pkgver=2.2.0
_testdatacommit=e3764a229ff98541884a3cd4bd7dc95f4ae5d466
pkgrel=6
pkgdesc="Reader for the MaxMind DB format"
url="https://github.com/maxmind/MaxMind-DB-Reader-python"
license=('Apache')
arch=('loong64' 'x86_64')
depends=('python' 'libmaxminddb')
makedepends=('python-setuptools')
checkdepends=('python-nose')
source=("https://github.com/maxmind/MaxMind-DB-Reader-python/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
        https://github.com/maxmind/MaxMind-DB-Reader-python/commit/42ed2df7e84bfc14645b075fc149a57213d3298d.patch
        https://github.com/maxmind/MaxMind-DB/archive/$_testdatacommit.tar.gz)
sha512sums=('f9848ba16c0b92cefe22d086634947cef7d741987387ee249976d18d14b01207ebede3cd76c52edd2fd465d38fcb784afe6953f255b9334311e12fec1c935feb'
            '212357570a2e8278bd525f2b77f02485c18cd4d48e56076a3d5200b8102fe98ceb229105e958794af20f41762f52c402d4d065b3291fd665ad5e97306bbd2efd'
            '618bef60b69492aecd06467428e36d7a10f2aa846e7afd507b6eac1f3a6ceceeb14ed95654b629c9d2638634a5184658236b644edccc99ae2d24e35d9d1f6db9')

prepare() {
  cd MaxMind-DB-Reader-python-$pkgver
  rmdir tests/data
  ln -s "$srcdir"/MaxMind-DB-$_testdatacommit tests/data

  # Fix version info
  patch -p1 -i ../42ed2df7e84bfc14645b075fc149a57213d3298d.patch
}

build() {
  cd MaxMind-DB-Reader-python-$pkgver
  python setup.py build
}

check() {
  cd MaxMind-DB-Reader-python-$pkgver
  python setup.py nosetests
}

package() {
  cd MaxMind-DB-Reader-python-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
}
